<template>
	<view class="main">
		<u-navbar title="精选推荐" :autoBack="true" :placeholder="true" :titleStyle="state.titleStyle" :height="40"
			bgColor="#F5F5F5">
		</u-navbar>
		<scroll-view scroll-y="true" lower-threshold="80" @scrolltolower="getGoodsList" class="marTop" v-if="state.list.length>0">
			<view class="all_list">
				<view class="block" v-for="item,index in state.list" :key="index" @click="sheep.$router.go('/pages/index/detail?id='+item.id+'&type=1')">
					<view class="img">
						<image :src="item.show_image" mode=""></image>
					</view>
					<view class="title">
						<image src="../../static/icon_v@2x.png" mode=""></image>
						<text class="ov1">{{item.title}}</text>
					</view>
					<view class="infos ov1">
						{{item.name}}·{{item.age}}·{{item.height}}
					</view>
					<view class="type" >
						<txet class="xiaobiao" v-for="(v,k) in item.lable_arr.show_lable">{{v.lable}}</txet>
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="wu" v-else>
			<image :src="state.url+'/useimage/chat_list.jpg'" mode=""></image>
			<!-- <image src="https://laiyu.1122334455.cn/useimage/chat_list.jpg" mode=""></image> -->
			<view class="cnei"> 该地区没有团长入驻，联系客服申请开通</view>
			<view class="lian" @click="router('/pages/index/chat')">联系客服</view>
		</view>
	</view>	
</template>

<script setup>
	import {
		ref,
		reactive,
	} from 'vue';
	import sheep from '@/sheep';
	import {
		onLoad,
	} from '@dcloudio/uni-app';
	const state = reactive({
		titleStyle: 'fontWeight:bold',
		address: '山东省',
		swiper: [],
		list: [],
		tabed: 0,
		
		list:[],
		pageSize:10,
		page:1,
		hasMore:true,
		isLoad:false,
		addressId:'',
		url:'',
	});
	onLoad((options) => {
		state.url = import.meta.env.BUZHENG_BASE_URL
		state.addressId = uni.getStorageSync('addressId')||2
		newsDatas()
		
	});
	// 倒计时
	function getLeft(){
		uni.navigateBack({
			delta:1,//返回层数，2则上上页
		})
	}
	function select(e) {
		this.tabed = e
	}
	function newsDatas(){
		state.page=1
		state.hasMore=true
		state.isLoad=false
		state.list=[]
		getGoodsList()
	}
	async function getGoodsList(){
		if(state.isLoad) return false
		if(!state.hasMore) return false
		state.isLoad=true
		const {code,data} = await sheep.$api.zqzApi.indexNews({
			city_id: state.addressId,
			recommend:1,
			page:state.page,
			limit:state.pageSize,
			
		})
		if (code == 1) {
			let list = data.list
			let hasmore = list.length===state.pageSize
			list = state.list.concat(list)
			state.hasMore = hasmore
			state.list = list
			state.isLoad = false
			state.page = state.page+1
		}
	}
</script>

<style lang="scss">
	.wu{
		text-align: center;
		padding:20rpx;
        padding-top:200rpx;
		image{
			width:340rpx;
			height: 284rpx;
		}
		.cnei{
			line-height: 80rpx;
			font-size:28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #333333;
		}
		.lian{
			margin: 10rpx auto 0;
			width: 400rpx;
			height:96rpx;
			line-height: 96rpx;
			background: #1BDDD0;
			border-radius:54rpx;
			color: #fff;
			font-size: 32rpx;
		}
		
	}
	.ov1{
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	page {
		height: 100%;
		width: 100%;
		background-color: #F5F5F5;
	}
	.main{
		height: 100%;
		width: 100%;
		background-color: #F5F5F5;
	}
	.marTop{
		margin-top: 90rpx;
		width: 100%;
		height: calc(100% - 40rpx);
	}
	.all_list {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		justify-content: space-between;
		width: calc(100% - 48rpx);
        margin:0 auto;
		padding-bottom: 100rpx;
		
	
		.block {
			width: 48%;
			height: 518rpx;
			background: #F8F8F8;
			border-radius: 24rpx;
			background-color: #fff;
			margin-bottom: 24rpx;
	
			.img {
				width: 100%;
				height: 332rpx;
				border-radius: 24rpx 24rpx 0 0;
				overflow: hidden;
	
				image {
					width: 100%;
					height: 332rpx;
				}
			}
	
			.title {
				display: flex;
				align-items: center;
				margin: 20rpx 24rpx 4rpx;
	
				image {
					height: 32rpx;
					width: 32rpx;
				}
	
				text {
					font-size: 32rpx;
					color: #333333;
					margin-left: 8rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
				}
			}
	
			.infos {
				font-size: 24rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #A5A5A5;
				margin: 4rpx 24rpx 12rpx;
			}
	
			.type {
				padding:0 24rpx;
				display: flex;
				.xiaobiao{
					padding:5rpx 8rpx;
					text-align: center;
					border-radius: 30rpx;
					font-size: 18rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					margin-right: 8rpx;
					background: #1BDDD0;
					color: #fff;
				}
				
			}
		}
	}
</style>